<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class MatchData - RDoc Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0-preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="Object.html">Object</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-i-3D-3D">#==</a>
    <li ><a href="#method-i-5B-5D">#[]</a>
    <li ><a href="#method-i-begin">#begin</a>
    <li ><a href="#method-i-byteoffset">#byteoffset</a>
    <li ><a href="#method-i-captures">#captures</a>
    <li ><a href="#method-i-deconstruct">#deconstruct</a>
    <li ><a href="#method-i-deconstruct_keys">#deconstruct_keys</a>
    <li ><a href="#method-i-end">#end</a>
    <li ><a href="#method-i-eql-3F">#eql?</a>
    <li ><a href="#method-i-hash">#hash</a>
    <li ><a href="#method-i-inspect">#inspect</a>
    <li ><a href="#method-i-length">#length</a>
    <li ><a href="#method-i-match">#match</a>
    <li ><a href="#method-i-match_length">#match_length</a>
    <li ><a href="#method-i-named_captures">#named_captures</a>
    <li ><a href="#method-i-names">#names</a>
    <li ><a href="#method-i-offset">#offset</a>
    <li ><a href="#method-i-post_match">#post_match</a>
    <li ><a href="#method-i-pre_match">#pre_match</a>
    <li ><a href="#method-i-regexp">#regexp</a>
    <li ><a href="#method-i-size">#size</a>
    <li ><a href="#method-i-string">#string</a>
    <li ><a href="#method-i-to_a">#to_a</a>
    <li ><a href="#method-i-to_s">#to_s</a>
    <li ><a href="#method-i-values_at">#values_at</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-MatchData">
    <h1 id="class-MatchData" class="class">
      class MatchData
    </h1>

    <section class="description">
    
<p><a href="MatchData.html"><code>MatchData</code></a> encapsulates the result of matching a <a href="Regexp.html"><code>Regexp</code></a> against string. It is returned by <a href="Regexp.html#method-i-match"><code>Regexp#match</code></a> and <a href="String.html#method-i-match"><code>String#match</code></a>, and also stored in a global variable returned by <a href="Regexp.html#method-c-last_match"><code>Regexp.last_match</code></a>.</p>

<p>Usage:</p>

<pre class="ruby"><span class="ruby-identifier">url</span> = <span class="ruby-string">&#39;https://docs.ruby-lang.org/en/2.5.0/MatchData.html&#39;</span>
<span class="ruby-identifier">m</span> = <span class="ruby-identifier">url</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">/(\d\.?)+/</span>)   <span class="ruby-comment"># =&gt; #&lt;MatchData &quot;2.5.0&quot; 1:&quot;0&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">string</span>                    <span class="ruby-comment"># =&gt; &quot;https://docs.ruby-lang.org/en/2.5.0/MatchData.html&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">regexp</span>                    <span class="ruby-comment"># =&gt; /(\d\.?)+/</span>
<span class="ruby-comment"># entire matched substring:</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>]                        <span class="ruby-comment"># =&gt; &quot;2.5.0&quot;</span>

<span class="ruby-comment"># Working with unnamed captures</span>
<span class="ruby-identifier">m</span> = <span class="ruby-identifier">url</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">%r{([^/]+)/([^/]+)\.html$}</span>)
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>                  <span class="ruby-comment"># =&gt; [&quot;2.5.0&quot;, &quot;MatchData&quot;]</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>]                        <span class="ruby-comment"># =&gt; &quot;2.5.0&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">values_at</span>(<span class="ruby-value">1</span>, <span class="ruby-value">2</span>)           <span class="ruby-comment"># =&gt; [&quot;2.5.0&quot;, &quot;MatchData&quot;]</span>

<span class="ruby-comment"># Working with named captures</span>
<span class="ruby-identifier">m</span> = <span class="ruby-identifier">url</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp">%r{(?&lt;version&gt;[^/]+)/(?&lt;module&gt;[^/]+)\.html$}</span>)
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>                  <span class="ruby-comment"># =&gt; [&quot;2.5.0&quot;, &quot;MatchData&quot;]</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">named_captures</span>            <span class="ruby-comment"># =&gt; {&quot;version&quot;=&gt;&quot;2.5.0&quot;, &quot;module&quot;=&gt;&quot;MatchData&quot;}</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">:version</span>]                 <span class="ruby-comment"># =&gt; &quot;2.5.0&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">values_at</span>(<span class="ruby-value">:version</span>, <span class="ruby-value">:module</span>)
                            <span class="ruby-comment"># =&gt; [&quot;2.5.0&quot;, &quot;MatchData&quot;]</span>
<span class="ruby-comment"># Numerical indexes are working, too</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>]                        <span class="ruby-comment"># =&gt; &quot;2.5.0&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">values_at</span>(<span class="ruby-value">1</span>, <span class="ruby-value">2</span>)           <span class="ruby-comment"># =&gt; [&quot;2.5.0&quot;, &quot;MatchData&quot;]</span>
</pre>

<h2 id="class-MatchData-label-Global+variables+equivalence">Global variables equivalence<span><a href="#class-MatchData-label-Global+variables+equivalence">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Parts of last <a href="MatchData.html"><code>MatchData</code></a> (returned by <a href="Regexp.html#method-c-last_match"><code>Regexp.last_match</code></a>) are also aliased as global variables:</p>
<ul><li>
<p><code>$~</code> is <a href="Regexp.html#method-c-last_match"><code>Regexp.last_match</code></a>;</p>
</li><li>
<p><code>$&amp;</code> is <a href="Regexp.html#method-c-last_match"><code>Regexp.last_match</code></a><code>[ 0 ]</code>;</p>
</li><li>
<p><code>$1</code>, <code>$2</code>, and so on are <a href="Regexp.html#method-c-last_match"><code>Regexp.last_match</code></a><code>[ i ]</code> (captures by number);</p>
</li><li>
<p><code>$`</code> is <a href="Regexp.html#method-c-last_match"><code>Regexp.last_match</code></a><code>.pre_match</code>;</p>
</li><li>
<p><code>$&#39;</code> is <a href="Regexp.html#method-c-last_match"><code>Regexp.last_match</code></a><code>.post_match</code>;</p>
</li><li>
<p><code>$+</code> is <a href="Regexp.html#method-c-last_match"><code>Regexp.last_match</code></a><code>[ -1 ]</code> (the last capture).</p>
</li></ul>

<p>See also “Special global variables” section in <a href="Regexp.html"><code>Regexp</code></a> documentation.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-3D-3D" class="method-detail method-alias">
                      <div class="method-heading">
                        <span class="method-callseq">
                          matchdata == object &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>object</code> is another MatchData object whose target string, regexp, match, and captures are the same as <code>self</code>, <code>false</code> otherwise.</p>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="MatchData.html#method-i-eql-3F">eql?</a>
                            </div>
                          </div>

                  <div id="method-i-5B-5D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          matchdata[index] &rarr; string or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          matchdata[start, length] &rarr; array
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          matchdata[range] &rarr; array
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          matchdata[name] &rarr; string or nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>When arguments <code>index</code>, +start and <code>length</code>, or <code>range</code> are given, returns match and captures in the style of <a href="Array.html#method-i-5B-5D"><code>Array#[]</code></a>:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>] <span class="ruby-comment"># =&gt; &quot;HX1138&quot;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>, <span class="ruby-value">2</span>]  <span class="ruby-comment"># =&gt; [&quot;H&quot;, &quot;X&quot;]</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">3</span>]  <span class="ruby-comment"># =&gt; [&quot;H&quot;, &quot;X&quot;, &quot;113&quot;]</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">-3</span>, <span class="ruby-value">2</span>] <span class="ruby-comment"># =&gt; [&quot;X&quot;, &quot;113&quot;]</span>
</pre>

<p>When string or symbol argument <code>name</code> is given, returns the matched substring for the given name:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;foo&gt;.)(.)(?&lt;bar&gt;.+)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;hoge&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;hoge&quot; foo:&quot;h&quot; bar:&quot;ge&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-string">&#39;foo&#39;</span>] <span class="ruby-comment"># =&gt; &quot;h&quot;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">:bar</span>]  <span class="ruby-comment"># =&gt; &quot;ge&quot;</span>
</pre>

                              <div class="method-source-code" id="5B-5D-source">
            <pre>static VALUE
match_aref(int argc, VALUE *argv, VALUE match)
{
    VALUE idx, length;

    match_check(match);
    rb_scan_args(argc, argv, &quot;11&quot;, &amp;idx, &amp;length);

    if (NIL_P(length)) {
        if (FIXNUM_P(idx)) {
            return rb_reg_nth_match(FIX2INT(idx), match);
        }
        else {
            int num = namev_to_backref_number(RMATCH_REGS(match), RMATCH(match)-&gt;regexp, idx);
            if (num &gt;= 0) {
                return rb_reg_nth_match(num, match);
            }
            else {
                return match_ary_aref(match, idx, Qnil);
            }
        }
    }
    else {
        long beg = NUM2LONG(idx);
        long len = NUM2LONG(length);
        long num_regs = RMATCH_REGS(match)-&gt;num_regs;
        if (len &lt; 0) {
            return Qnil;
        }
        if (beg &lt; 0) {
            beg += num_regs;
            if (beg &lt; 0) return Qnil;
        }
        else if (beg &gt; num_regs) {
            return Qnil;
        }
        if (beg+len &gt; num_regs) {
            len = num_regs - beg;
        }
        return match_ary_subseq(match, beg, len, Qnil);
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-begin" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          begin(n) &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          begin(name) &rarr; integer
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns the offset (in characters) of the beginning of the specified match.</p>

<p>When non-negative integer argument <code>n</code> is given, returns the offset of the beginning of the <code>n</code>th match:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>]       <span class="ruby-comment"># =&gt; &quot;HX1138&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">0</span>) <span class="ruby-comment"># =&gt; 1</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">3</span>]       <span class="ruby-comment"># =&gt; &quot;113&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; 3</span>

<span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(т)(е)(с)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&#39;тест&#39;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;тес&quot; 1:&quot;т&quot; 2:&quot;е&quot; 3:&quot;с&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>]       <span class="ruby-comment"># =&gt; &quot;тес&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">0</span>) <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">3</span>]       <span class="ruby-comment"># =&gt; &quot;с&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; 2</span>
</pre>

<p>When string or symbol argument <code>name</code> is given, returns the offset of the beginning for the named match:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;foo&gt;.)(.)(?&lt;bar&gt;.)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;hoge&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;hog&quot; foo:&quot;h&quot; bar:&quot;g&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">:foo</span>]        <span class="ruby-comment"># =&gt; &quot;h&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">:bar</span>]        <span class="ruby-comment"># =&gt; &quot;g&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">:bar</span>)  <span class="ruby-comment"># =&gt; 2</span>
</pre>

<p>Related: <a href="MatchData.html#method-i-end"><code>MatchData#end</code></a>, <a href="MatchData.html#method-i-offset"><code>MatchData#offset</code></a>, <a href="MatchData.html#method-i-byteoffset"><code>MatchData#byteoffset</code></a>.</p>

                              <div class="method-source-code" id="begin-source">
            <pre>static VALUE
match_begin(VALUE match, VALUE n)
{
    int i = match_backref_number(match, n);
    struct re_registers *regs = RMATCH_REGS(match);

    match_check(match);
    backref_number_check(regs, i);

    if (BEG(i) &lt; 0)
        return Qnil;

    update_char_offset(match);
    return LONG2NUM(RMATCH_EXT(match)-&gt;char_offset[i].beg);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-byteoffset" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          byteoffset(n)   &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a two-element array containing the beginning and ending byte-based offsets of the <em>n</em>th match. <em>n</em> can be a string or symbol to reference a named capture.</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">byteoffset</span>(<span class="ruby-value">0</span>)      <span class="ruby-comment">#=&gt; [1, 7]</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">byteoffset</span>(<span class="ruby-value">4</span>)      <span class="ruby-comment">#=&gt; [6, 7]</span>

<span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;foo&gt;.)(.)(?&lt;bar&gt;.)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;hoge&quot;</span>)
<span class="ruby-identifier">p</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">byteoffset</span>(<span class="ruby-value">:foo</span>) <span class="ruby-comment">#=&gt; [0, 1]</span>
<span class="ruby-identifier">p</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">byteoffset</span>(<span class="ruby-value">:bar</span>) <span class="ruby-comment">#=&gt; [2, 3]</span>
</pre>

                              <div class="method-source-code" id="byteoffset-source">
            <pre>static VALUE
match_byteoffset(VALUE match, VALUE n)
{
    int i = match_backref_number(match, n);
    struct re_registers *regs = RMATCH_REGS(match);

    match_check(match);
    backref_number_check(regs, i);

    if (BEG(i) &lt; 0)
        return rb_assoc_new(Qnil, Qnil);
    return rb_assoc_new(LONG2NUM(BEG(i)), LONG2NUM(END(i)));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-captures" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          captures &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the array of captures, which are all matches except <code>m[0]</code>:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>]       <span class="ruby-comment"># =&gt; &quot;HX1138&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span> <span class="ruby-comment"># =&gt; [&quot;H&quot;, &quot;X&quot;, &quot;113&quot;, &quot;8&quot;]</span>
</pre>

<p>Related: <a href="MatchData.html#method-i-to_a"><code>MatchData.to_a</code></a>.</p>

                              <div class="method-source-code" id="captures-source">
            <pre>static VALUE
match_captures(VALUE match)
{
    return match_array(match, 1);
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="MatchData.html#method-i-deconstruct">deconstruct</a>
                            </div>

                          </div>

                  <div id="method-i-deconstruct" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">deconstruct</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the array of captures, which are all matches except <code>m[0]</code>:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>]       <span class="ruby-comment"># =&gt; &quot;HX1138&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span> <span class="ruby-comment"># =&gt; [&quot;H&quot;, &quot;X&quot;, &quot;113&quot;, &quot;8&quot;]</span>
</pre>

<p>Related: <a href="MatchData.html#method-i-to_a"><code>MatchData.to_a</code></a>.</p>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="MatchData.html#method-i-captures">captures</a>
                            </div>
                          </div>

                  <div id="method-i-deconstruct_keys" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          deconstruct_keys(array_of_names) &rarr; hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a hash of the named captures for the given names.</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;hours&gt;\d{2}):(?&lt;minutes&gt;\d{2}):(?&lt;seconds&gt;\d{2})/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;18:37:22&quot;</span>)
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">deconstruct_keys</span>([<span class="ruby-value">:hours</span>, <span class="ruby-value">:minutes</span>]) <span class="ruby-comment"># =&gt; {:hours =&gt; &quot;18&quot;, :minutes =&gt; &quot;37&quot;}</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">deconstruct_keys</span>(<span class="ruby-keyword">nil</span>) <span class="ruby-comment"># =&gt; {:hours =&gt; &quot;18&quot;, :minutes =&gt; &quot;37&quot;, :seconds =&gt; &quot;22&quot;}</span>
</pre>

<p>Returns an empty hash of no named captures were defined:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(\d{2}):(\d{2}):(\d{2})/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;18:37:22&quot;</span>)
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">deconstruct_keys</span>(<span class="ruby-keyword">nil</span>) <span class="ruby-comment"># =&gt; {}</span>
</pre>

                              <div class="method-source-code" id="deconstruct_keys-source">
            <pre>static VALUE
match_deconstruct_keys(VALUE match, VALUE keys)
{
    VALUE h;
    long i;

    match_check(match);

    if (NIL_P(RMATCH(match)-&gt;regexp)) {
        return rb_hash_new_with_size(0);
    }

    if (NIL_P(keys)) {
        h = rb_hash_new_with_size(onig_number_of_names(RREGEXP_PTR(RMATCH(match)-&gt;regexp)));

        struct MEMO *memo;
        memo = MEMO_NEW(h, match, 1);

        onig_foreach_name(RREGEXP_PTR(RMATCH(match)-&gt;regexp), match_named_captures_iter, (void*)memo);

        return h;
    }

    Check_Type(keys, T_ARRAY);

    if (onig_number_of_names(RREGEXP_PTR(RMATCH(match)-&gt;regexp)) &lt; RARRAY_LEN(keys)) {
        return rb_hash_new_with_size(0);
    }

    h = rb_hash_new_with_size(RARRAY_LEN(keys));

    for (i=0; i&lt;RARRAY_LEN(keys); i++) {
        VALUE key = RARRAY_AREF(keys, i);
        VALUE name;

        Check_Type(key, T_SYMBOL);

        name = rb_sym2str(key);

        int num = NAME_TO_NUMBER(RMATCH_REGS(match), RMATCH(match)-&gt;regexp, RMATCH(match)-&gt;regexp,
                         RSTRING_PTR(name), RSTRING_END(name));

        if (num &gt;= 0) {
            rb_hash_aset(h, key, rb_reg_nth_match(num, match));
        }
        else {
            return h;
        }
    }

    return h;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-end" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          end(n) &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          end(name) &rarr; integer
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns the offset (in characters) of the end of the specified match.</p>

<p>When non-negative integer argument <code>n</code> is given, returns the offset of the end of the <code>n</code>th match:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>]     <span class="ruby-comment"># =&gt; &quot;HX1138&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">0</span>) <span class="ruby-comment"># =&gt; 7</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">3</span>]     <span class="ruby-comment"># =&gt; &quot;113&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; 6</span>

<span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(т)(е)(с)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&#39;тест&#39;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;тес&quot; 1:&quot;т&quot; 2:&quot;е&quot; 3:&quot;с&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>]     <span class="ruby-comment"># =&gt; &quot;тес&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">0</span>) <span class="ruby-comment"># =&gt; 3</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">3</span>]     <span class="ruby-comment"># =&gt; &quot;с&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; 3</span>
</pre>

<p>When string or symbol argument <code>name</code> is given, returns the offset of the end for the named match:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;foo&gt;.)(.)(?&lt;bar&gt;.)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;hoge&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;hog&quot; foo:&quot;h&quot; bar:&quot;g&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">:foo</span>]      <span class="ruby-comment"># =&gt; &quot;h&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">end</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; 1</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">:bar</span>]      <span class="ruby-comment"># =&gt; &quot;g&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">:bar</span>)  <span class="ruby-comment"># =&gt; 3</span>
</pre>

<p>Related: <a href="MatchData.html#method-i-begin"><code>MatchData#begin</code></a>, <a href="MatchData.html#method-i-offset"><code>MatchData#offset</code></a>, <a href="MatchData.html#method-i-byteoffset"><code>MatchData#byteoffset</code></a>.</p>

                              <div class="method-source-code" id="end-source">
            <pre>static VALUE
match_end(VALUE match, VALUE n)
{
    int i = match_backref_number(match, n);
    struct re_registers *regs = RMATCH_REGS(match);

    match_check(match);
    backref_number_check(regs, i);

    if (BEG(i) &lt; 0)
        return Qnil;

    update_char_offset(match);
    return LONG2NUM(RMATCH_EXT(match)-&gt;char_offset[i].end);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-eql-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">eql?</span><span
                                class="method-args"> == object -&gt; true or false</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>object</code> is another MatchData object whose target string, regexp, match, and captures are the same as <code>self</code>, <code>false</code> otherwise.</p>

                              <div class="method-source-code" id="eql-3F-source">
            <pre>static VALUE
match_equal(VALUE match1, VALUE match2)
{
    const struct re_registers *regs1, *regs2;

    if (match1 == match2) return Qtrue;
    if (!RB_TYPE_P(match2, T_MATCH)) return Qfalse;
    if (!RMATCH(match1)-&gt;regexp || !RMATCH(match2)-&gt;regexp) return Qfalse;
    if (!rb_str_equal(RMATCH(match1)-&gt;str, RMATCH(match2)-&gt;str)) return Qfalse;
    if (!rb_reg_equal(match_regexp(match1), match_regexp(match2))) return Qfalse;
    regs1 = RMATCH_REGS(match1);
    regs2 = RMATCH_REGS(match2);
    if (regs1-&gt;num_regs != regs2-&gt;num_regs) return Qfalse;
    if (memcmp(regs1-&gt;beg, regs2-&gt;beg, regs1-&gt;num_regs * sizeof(*regs1-&gt;beg))) return Qfalse;
    if (memcmp(regs1-&gt;end, regs2-&gt;end, regs1-&gt;num_regs * sizeof(*regs1-&gt;end))) return Qfalse;
    return Qtrue;
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="MatchData.html#method-i-3D-3D">==</a>
                            </div>

                          </div>

                  <div id="method-i-hash" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          hash &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the integer hash value for <code>self</code>, based on the target string, regexp, match, and captures.</p>

<p>See also <a href="Object.html#method-i-hash"><code>Object#hash</code></a>.</p>

                              <div class="method-source-code" id="hash-source">
            <pre>static VALUE
match_hash(VALUE match)
{
    const struct re_registers *regs;
    st_index_t hashval;

    match_check(match);
    hashval = rb_hash_start(rb_str_hash(RMATCH(match)-&gt;str));
    hashval = rb_hash_uint(hashval, reg_hash(match_regexp(match)));
    regs = RMATCH_REGS(match);
    hashval = rb_hash_uint(hashval, regs-&gt;num_regs);
    hashval = rb_hash_uint(hashval, rb_memhash(regs-&gt;beg, regs-&gt;num_regs * sizeof(*regs-&gt;beg)));
    hashval = rb_hash_uint(hashval, rb_memhash(regs-&gt;end, regs-&gt;num_regs * sizeof(*regs-&gt;end)));
    hashval = rb_hash_end(hashval);
    return ST2FIX(hashval);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inspect" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          inspect &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string representation of <code>self</code>:</p>

<pre>  m = /.$/.match(&quot;foo&quot;)
  # =&gt; #&lt;MatchData &quot;o&quot;&gt;
  m.inspect # =&gt; &quot;#&lt;MatchData \&quot;o\&quot;&gt;&quot;

  m = /(.)(.)(.)/.match(&quot;foo&quot;)
  # =&gt; #&lt;MatchData &quot;foo&quot; 1:&quot;f&quot; 2:&quot;o&quot; 3:&quot;o&quot;&gt;
  m.inspect # =&gt; &quot;#&lt;MatchData \&quot;foo\&quot; 1:\&quot;f\&quot; 2:\&quot;o\

  m = /(.)(.)?(.)/.match(&quot;fo&quot;)
  # =&gt; #&lt;MatchData &quot;fo&quot; 1:&quot;f&quot; 2:nil 3:&quot;o&quot;&gt;
  m.inspect # =&gt; &quot;#&lt;MatchData \&quot;fo\&quot; 1:\&quot;f\&quot; 2:nil 3:\&quot;o\&quot;&gt;&quot;

Related: MatchData#to_s.</pre>

                              <div class="method-source-code" id="inspect-source">
            <pre>static VALUE
match_inspect(VALUE match)
{
    VALUE cname = rb_class_path(rb_obj_class(match));
    VALUE str;
    int i;
    struct re_registers *regs = RMATCH_REGS(match);
    int num_regs = regs-&gt;num_regs;
    struct backref_name_tag *names;
    VALUE regexp = RMATCH(match)-&gt;regexp;

    if (regexp == 0) {
        return rb_sprintf(&quot;#&lt;%&quot;PRIsVALUE&quot;:%p&gt;&quot;, cname, (void*)match);
    }
    else if (NIL_P(regexp)) {
        return rb_sprintf(&quot;#&lt;%&quot;PRIsVALUE&quot;: %&quot;PRIsVALUE&quot;&gt;&quot;,
                          cname, rb_reg_nth_match(0, match));
    }

    names = ALLOCA_N(struct backref_name_tag, num_regs);
    MEMZERO(names, struct backref_name_tag, num_regs);

    onig_foreach_name(RREGEXP_PTR(regexp),
            match_inspect_name_iter, names);

    str = rb_str_buf_new2(&quot;#&lt;&quot;);
    rb_str_append(str, cname);

    for (i = 0; i &lt; num_regs; i++) {
        VALUE v;
        rb_str_buf_cat2(str, &quot; &quot;);
        if (0 &lt; i) {
            if (names[i].name)
                rb_str_buf_cat(str, (const char *)names[i].name, names[i].len);
            else {
                rb_str_catf(str, &quot;%d&quot;, i);
            }
            rb_str_buf_cat2(str, &quot;:&quot;);
        }
        v = rb_reg_nth_match(i, match);
        if (NIL_P(v))
            rb_str_buf_cat2(str, &quot;nil&quot;);
        else
            rb_str_buf_append(str, rb_str_inspect(v));
    }
    rb_str_buf_cat2(str, &quot;&gt;&quot;);

    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-length" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">length</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              <p>Returns size of the match array:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">size</span> <span class="ruby-comment"># =&gt; 5</span>
</pre>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="MatchData.html#method-i-size">size</a>
                            </div>
                          </div>

                  <div id="method-i-match" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          match(n) &rarr; string or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          match(name) &rarr; string or nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns the matched substring corresponding to the given argument.</p>

<p>When non-negative argument <code>n</code> is given, returns the matched substring for the <code>n</code>th match:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)(\w)?/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot; 5:nil&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">match</span>(<span class="ruby-value">0</span>) <span class="ruby-comment"># =&gt; &quot;HX1138&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">match</span>(<span class="ruby-value">4</span>) <span class="ruby-comment"># =&gt; &quot;8&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">match</span>(<span class="ruby-value">5</span>) <span class="ruby-comment"># =&gt; nil</span>
</pre>

<p>When string or symbol argument <code>name</code> is given, returns the matched substring for the given name:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;foo&gt;.)(.)(?&lt;bar&gt;.+)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;hoge&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;hoge&quot; foo:&quot;h&quot; bar:&quot;ge&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; &quot;h&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">match</span>(<span class="ruby-value">:bar</span>)  <span class="ruby-comment"># =&gt; &quot;ge&quot;</span>
</pre>

                              <div class="method-source-code" id="match-source">
            <pre>static VALUE
match_nth(VALUE match, VALUE n)
{
    int i = match_backref_number(match, n);
    struct re_registers *regs = RMATCH_REGS(match);

    backref_number_check(regs, i);

    long start = BEG(i), end = END(i);
    if (start &lt; 0)
        return Qnil;

    return rb_str_subseq(RMATCH(match)-&gt;str, start, end - start);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-match_length" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          match_length(n) &rarr; integer or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          match_length(name) &rarr; integer or nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns the length (in characters) of the matched substring corresponding to the given argument.</p>

<p>When non-negative argument <code>n</code> is given, returns the length of the matched substring for the <code>n</code>th match:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)(\w)?/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot; 5:nil&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">match_length</span>(<span class="ruby-value">0</span>) <span class="ruby-comment"># =&gt; 6</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">match_length</span>(<span class="ruby-value">4</span>) <span class="ruby-comment"># =&gt; 1</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">match_length</span>(<span class="ruby-value">5</span>) <span class="ruby-comment"># =&gt; nil</span>
</pre>

<p>When string or symbol argument <code>name</code> is given, returns the length of the matched substring for the named match:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;foo&gt;.)(.)(?&lt;bar&gt;.+)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;hoge&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;hoge&quot; foo:&quot;h&quot; bar:&quot;ge&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">match_length</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; 1</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">match_length</span>(<span class="ruby-value">:bar</span>)  <span class="ruby-comment"># =&gt; 2</span>
</pre>

                              <div class="method-source-code" id="match_length-source">
            <pre>static VALUE
match_nth_length(VALUE match, VALUE n)
{
    int i = match_backref_number(match, n);
    struct re_registers *regs = RMATCH_REGS(match);

    match_check(match);
    backref_number_check(regs, i);

    if (BEG(i) &lt; 0)
        return Qnil;

    update_char_offset(match);
    const struct rmatch_offset *const ofs =
        &amp;RMATCH_EXT(match)-&gt;char_offset[i];
    return LONG2NUM(ofs-&gt;end - ofs-&gt;beg);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-named_captures" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          named_captures(symbolize_names: false) &rarr; hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <pre>Returns a hash of the named captures;
each key is a capture name; each value is its captured string or +nil+:

  m = /(?&lt;foo&gt;.)(.)(?&lt;bar&gt;.+)/.match(&quot;hoge&quot;)
  # =&gt; #&lt;MatchData &quot;hoge&quot; foo:&quot;h&quot; bar:&quot;ge&quot;&gt;
  m.named_captures # =&gt; {&quot;foo&quot;=&gt;&quot;h&quot;, &quot;bar&quot;=&gt;&quot;ge&quot;}

  m = /(?&lt;a&gt;.)(?&lt;b&gt;.)/.match(&quot;01&quot;)
  # =&gt; #&lt;MatchData &quot;01&quot; a:&quot;0&quot; b:&quot;1&quot;&gt;
  m.named_captures #=&gt; {&quot;a&quot; =&gt; &quot;0&quot;, &quot;b&quot; =&gt; &quot;1&quot;}

  m = /(?&lt;a&gt;.)(?&lt;b&gt;.)?/.match(&quot;0&quot;)
  # =&gt; #&lt;MatchData &quot;0&quot; a:&quot;0&quot; b:nil&gt;
  m.named_captures #=&gt; {&quot;a&quot; =&gt; &quot;0&quot;, &quot;b&quot; =&gt; nil}

  m = /(?&lt;a&gt;.)(?&lt;a&gt;.)/.match(&quot;01&quot;)
  # =&gt; #&lt;MatchData &quot;01&quot; a:&quot;0&quot; a:&quot;1&quot;&gt;
  m.named_captures #=&gt; {&quot;a&quot; =&gt; &quot;1&quot;}</pre>

<p>If keyword argument <code>symbolize_names</code> is given a true value, the keys in the resulting hash are Symbols:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;a&gt;.)(?&lt;a&gt;.)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;01&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;01&quot; a:&quot;0&quot; a:&quot;1&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">named_captures</span>(<span class="ruby-value">symbolize_names:</span> <span class="ruby-keyword">true</span>) <span class="ruby-comment">#=&gt; {:a =&gt; &quot;1&quot;}</span>
</pre>

                              <div class="method-source-code" id="named_captures-source">
            <pre>static VALUE
match_named_captures(int argc, VALUE *argv, VALUE match)
{
    VALUE hash;
    struct MEMO *memo;

    match_check(match);
    if (NIL_P(RMATCH(match)-&gt;regexp))
        return rb_hash_new();

    VALUE opt;
    VALUE symbolize_names = 0;

    rb_scan_args(argc, argv, &quot;0:&quot;, &amp;opt);

    if (!NIL_P(opt)) {
        static ID keyword_ids[1];

        VALUE symbolize_names_val;

        if (!keyword_ids[0]) {
            keyword_ids[0] = rb_intern_const(&quot;symbolize_names&quot;);
        }
        rb_get_kwargs(opt, keyword_ids, 0, 1, &amp;symbolize_names_val);
        if (!UNDEF_P(symbolize_names_val) &amp;&amp; RTEST(symbolize_names_val)) {
            symbolize_names = 1;
        }
    }

    hash = rb_hash_new();
    memo = MEMO_NEW(hash, match, symbolize_names);

    onig_foreach_name(RREGEXP(RMATCH(match)-&gt;regexp)-&gt;ptr, match_named_captures_iter, (void*)memo);

    return hash;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-names" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          names &rarr; array_of_names
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of the capture names (see <a href="Regexp.html#class-Regexp-label-Named+Captures">Named Captures</a>):</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;foo&gt;.)(?&lt;bar&gt;.)(?&lt;baz&gt;.)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;hoge&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;hog&quot; foo:&quot;h&quot; bar:&quot;o&quot; baz:&quot;g&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">names</span> <span class="ruby-comment"># =&gt; [&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;]</span>

<span class="ruby-identifier">m</span> = <span class="ruby-regexp">/foo/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; #&lt;MatchData &quot;foo&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">names</span> <span class="ruby-comment"># =&gt; [] # No named captures.</span>
</pre>

<p>Equivalent to:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;foo&gt;.)(?&lt;bar&gt;.)(?&lt;baz&gt;.)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;hoge&quot;</span>)
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">regexp</span>.<span class="ruby-identifier">names</span> <span class="ruby-comment"># =&gt; [&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;]</span>
</pre>

                              <div class="method-source-code" id="names-source">
            <pre>static VALUE
match_names(VALUE match)
{
    match_check(match);
    if (NIL_P(RMATCH(match)-&gt;regexp))
        return rb_ary_new_capa(0);
    return rb_reg_names(RMATCH(match)-&gt;regexp);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-offset" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          offset(n) &rarr; [start_offset, end_offset]
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          offset(name) &rarr; [start_offset, end_offset]
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns a 2-element array containing the beginning and ending offsets (in characters) of the specified match.</p>

<p>When non-negative integer argument <code>n</code> is given, returns the starting and ending offsets of the <code>n</code>th match:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>]        <span class="ruby-comment"># =&gt; &quot;HX1138&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">offset</span>(<span class="ruby-value">0</span>) <span class="ruby-comment"># =&gt; [1, 7]</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">3</span>]        <span class="ruby-comment"># =&gt; &quot;113&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">offset</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; [3, 6]</span>

<span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(т)(е)(с)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&#39;тест&#39;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;тес&quot; 1:&quot;т&quot; 2:&quot;е&quot; 3:&quot;с&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>]        <span class="ruby-comment"># =&gt; &quot;тес&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">offset</span>(<span class="ruby-value">0</span>) <span class="ruby-comment"># =&gt; [0, 3]</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">3</span>]        <span class="ruby-comment"># =&gt; &quot;с&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">offset</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; [2, 3]</span>
</pre>

<p>When string or symbol argument <code>name</code> is given, returns the starting and ending offsets for the named match:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;foo&gt;.)(.)(?&lt;bar&gt;.)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;hoge&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;hog&quot; foo:&quot;h&quot; bar:&quot;g&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">:foo</span>]         <span class="ruby-comment"># =&gt; &quot;h&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">offset</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># =&gt; [0, 1]</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">:bar</span>]         <span class="ruby-comment"># =&gt; &quot;g&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">offset</span>(<span class="ruby-value">:bar</span>)  <span class="ruby-comment"># =&gt; [2, 3]</span>
</pre>

<p>Related: <a href="MatchData.html#method-i-byteoffset"><code>MatchData#byteoffset</code></a>, <a href="MatchData.html#method-i-begin"><code>MatchData#begin</code></a>, <a href="MatchData.html#method-i-end"><code>MatchData#end</code></a>.</p>

                              <div class="method-source-code" id="offset-source">
            <pre>static VALUE
match_offset(VALUE match, VALUE n)
{
    int i = match_backref_number(match, n);
    struct re_registers *regs = RMATCH_REGS(match);

    match_check(match);
    backref_number_check(regs, i);

    if (BEG(i) &lt; 0)
        return rb_assoc_new(Qnil, Qnil);

    update_char_offset(match);
    return rb_assoc_new(LONG2NUM(RMATCH_EXT(match)-&gt;char_offset[i].beg),
                        LONG2NUM(RMATCH_EXT(match)-&gt;char_offset[i].end));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-post_match" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          post_match   &rarr; str
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the substring of the target string from the end of the first match in <code>self</code> (that is, <code>self[0]</code>) to the end of the string; equivalent to regexp global variable <code>$&#39;</code>:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138: The Movie&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>]         <span class="ruby-comment"># =&gt; &quot;HX1138&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">post_match</span> <span class="ruby-comment"># =&gt; &quot;: The Movie&quot;\</span>
</pre>

<p>Related: <a href="MatchData.html#method-i-pre_match"><code>MatchData.pre_match</code></a>.</p>

                              <div class="method-source-code" id="post_match-source">
            <pre>VALUE
rb_reg_match_post(VALUE match)
{
    VALUE str;
    long pos;
    struct re_registers *regs;

    if (NIL_P(match)) return Qnil;
    match_check(match);
    regs = RMATCH_REGS(match);
    if (BEG(0) == -1) return Qnil;
    str = RMATCH(match)-&gt;str;
    pos = END(0);
    str = rb_str_subseq(str, pos, RSTRING_LEN(str) - pos);
    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-pre_match" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          pre_match &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the substring of the target string from its beginning up to the first match in <code>self</code> (that is, <code>self[0]</code>); equivalent to regexp global variable <code>$`</code>:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>[<span class="ruby-value">0</span>]        <span class="ruby-comment"># =&gt; &quot;HX1138&quot;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">pre_match</span> <span class="ruby-comment"># =&gt; &quot;T&quot;</span>
</pre>

<p>Related: <a href="MatchData.html#method-i-post_match"><code>MatchData#post_match</code></a>.</p>

                              <div class="method-source-code" id="pre_match-source">
            <pre>VALUE
rb_reg_match_pre(VALUE match)
{
    VALUE str;
    struct re_registers *regs;

    if (NIL_P(match)) return Qnil;
    match_check(match);
    regs = RMATCH_REGS(match);
    if (BEG(0) == -1) return Qnil;
    str = rb_str_subseq(RMATCH(match)-&gt;str, 0, BEG(0));
    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-regexp" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          regexp &rarr; regexp
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the regexp that produced the match:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/a.*b/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;abc&quot;</span>) <span class="ruby-comment"># =&gt; #&lt;MatchData &quot;ab&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">regexp</span>                <span class="ruby-comment"># =&gt; /a.*b/</span>
</pre>

                              <div class="method-source-code" id="regexp-source">
            <pre>static VALUE
match_regexp(VALUE match)
{
    VALUE regexp;
    match_check(match);
    regexp = RMATCH(match)-&gt;regexp;
    if (NIL_P(regexp)) {
        VALUE str = rb_reg_nth_match(0, match);
        regexp = rb_reg_regcomp(rb_reg_quote(str));
        RB_OBJ_WRITE(match, &amp;RMATCH(match)-&gt;regexp, regexp);
    }
    return regexp;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-size" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          size &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns size of the match array:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">size</span> <span class="ruby-comment"># =&gt; 5</span>
</pre>

                              <div class="method-source-code" id="size-source">
            <pre>static VALUE
match_size(VALUE match)
{
    match_check(match);
    return INT2FIX(RMATCH_REGS(match)-&gt;num_regs);
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="MatchData.html#method-i-length">length</a>
                            </div>

                          </div>

                  <div id="method-i-string" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          string &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the target string if it was frozen; otherwise, returns a frozen copy of the target string:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">string</span> <span class="ruby-comment"># =&gt; &quot;THX1138.&quot;</span>
</pre>

                              <div class="method-source-code" id="string-source">
            <pre>static VALUE
match_string(VALUE match)
{
    match_check(match);
    return RMATCH(match)-&gt;str;  /* str is frozen */
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_a" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_a &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the array of matches:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">to_a</span> <span class="ruby-comment"># =&gt; [&quot;HX1138&quot;, &quot;H&quot;, &quot;X&quot;, &quot;113&quot;, &quot;8&quot;]</span>
</pre>

<p>Related: <a href="MatchData.html#method-i-captures"><code>MatchData#captures</code></a>.</p>

                              <div class="method-source-code" id="to_a-source">
            <pre>static VALUE
match_to_a(VALUE match)
{
    return match_array(match, 0);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_s" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_s &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the matched string:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138.&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-comment"># =&gt; &quot;HX1138&quot;</span>

<span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;foo&gt;.)(.)(?&lt;bar&gt;.+)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;hoge&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;hoge&quot; foo:&quot;h&quot; bar:&quot;ge&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-comment"># =&gt; &quot;hoge&quot;</span>
</pre>

<p>Related: <a href="MatchData.html#method-i-inspect"><code>MatchData.inspect</code></a>.</p>

                              <div class="method-source-code" id="to_s-source">
            <pre>static VALUE
match_to_s(VALUE match)
{
    VALUE str = rb_reg_last_match(match_check(match));

    if (NIL_P(str)) str = rb_str_new(0,0);
    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-values_at" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          values_at(*indexes) &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns match and captures at the given <code>indexes</code>, which may include any mixture of:</p>
<ul><li>
<p>Integers.</p>
</li><li>
<p>Ranges.</p>
</li><li>
<p>Names (strings and symbols).</p>
</li></ul>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(.)(.)(\d+)(\d)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;THX1138: The Movie&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;HX1138&quot; 1:&quot;H&quot; 2:&quot;X&quot; 3:&quot;113&quot; 4:&quot;8&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">values_at</span>(<span class="ruby-value">0</span>, <span class="ruby-value">2</span>, <span class="ruby-value">-2</span>) <span class="ruby-comment"># =&gt; [&quot;HX1138&quot;, &quot;X&quot;, &quot;113&quot;]</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">values_at</span>(<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">2</span>, <span class="ruby-value">-1</span>) <span class="ruby-comment"># =&gt; [&quot;H&quot;, &quot;X&quot;, &quot;8&quot;]</span>

<span class="ruby-identifier">m</span> = <span class="ruby-regexp">/(?&lt;a&gt;\d+) *(?&lt;op&gt;[+\-*\/]) *(?&lt;b&gt;\d+)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-string">&quot;1 + 2&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;MatchData &quot;1 + 2&quot; a:&quot;1&quot; op:&quot;+&quot; b:&quot;2&quot;&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">values_at</span>(<span class="ruby-value">0</span>, <span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">2</span>, <span class="ruby-value">:a</span>, <span class="ruby-value">:b</span>, <span class="ruby-value">:op</span>)
<span class="ruby-comment"># =&gt; [&quot;1 + 2&quot;, &quot;1&quot;, &quot;+&quot;, &quot;1&quot;, &quot;2&quot;, &quot;+&quot;]</span>
</pre>

                              <div class="method-source-code" id="values_at-source">
            <pre>static VALUE
match_values_at(int argc, VALUE *argv, VALUE match)
{
    VALUE result;
    int i;

    match_check(match);
    result = rb_ary_new2(argc);

    for (i=0; i&lt;argc; i++) {
        if (FIXNUM_P(argv[i])) {
            rb_ary_push(result, rb_reg_nth_match(FIX2INT(argv[i]), match));
        }
        else {
            int num = namev_to_backref_number(RMATCH_REGS(match), RMATCH(match)-&gt;regexp, argv[i]);
            if (num &gt;= 0) {
                rb_ary_push(result, rb_reg_nth_match(num, match));
            }
            else {
                match_ary_aref(match, argv[i], result);
            }
        }
    }
    return result;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

